$(function () {
    checkSharedPage();
    //班级分享
    setTimeout(function(){
        if(isWeiXin()){
            //初始化微信分享
            initializeWxShare({
                title:$(".lecture-time").text(),
                desc:$(".teacher-info-box .wm-txt-small").text(),
                url:window.location.href,
                img:$("header .wm-img").attr("src")
            });
        }
    },1000);
    var teacherId = $("#teacher-id").val();
    var isQuestion = $("#isQuestion").val();
    tFaceFn();
    if(isQuestion==1){
        getQuestionList(1);
    }else{
        getTeacherCourseList(1);
    }

    $("body").on('click','.course-info',function () {//跳转课程详情
       var _this = $(this);
       var courseId = _this.data("id");//课程ID
        var courseTypeKey = _this.data('type');//课程类型
        if(courseTypeKey=='LIVE'){
            window.location.href = baseloaction +'/mobile/course/liveInfo?courseId='+courseId;
        }else{
            window.location.href = baseloaction +'/mobile/course/info?courseId='+courseId;
        }
    });

    //头像交互效果
    function tFaceFn() {
        $('.infinite-scroll').on('scroll', function () {
            var that = $(this),
                stop = that.scrollTop();

            if(stop > 20) {
                $('.bar-nav').addClass('faceSmall')
            } else {
                $('.bar-nav').removeClass('faceSmall')
            }
        })
    }

    /**
     * 查询讲师问题列表
     * @param pageNo
     */
    function getQuestionList(pageNo) {
        var params = {"status":1,"teacherId":teacherId};
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/qa/queryQuestionList',
            params: params,
            pageNo: pageNo,
            contextId: 'question-list-content',
            pageCall: getQuestionList,
            callback: function (pageNo) {
                $("#count").html('问题列表（'+ total +'）');
            }
        })
    }

    /**
     * 获取老师的课程列表
     * @param pageNo 页码
     */
    function getTeacherCourseList(pageNo){
        var params = {"teacherIds":teacherId};
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/course/ajaxTeacherCourseList',
            params: params,
            pageNo: pageNo,
            contextId: 'question-list-content',
            pageCall: getTeacherCourseList,
            callback: function (pageNo) {
                $("#count").html('课程列表（'+ total +'）');
            }
        })
    }

    /**
     * 讲师详情更多
     */
    textInfoMore()

});
